#include <bits/stdc++.h>

#define mp make_pair
#define se second
#define fi first
#define pdd pair<double, double>

using namespace std;

const int N = 1e5 + 10;
const double eps = 1e-8;

int n, m;
double v[N], d[N], a[N], L, V, p[N];
vector<pdd> x;

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T;
    scanf("%d", &T);
    while (T -- )
    {
        x.clear();
        scanf("%d%d%lf%lf", &n, &m, &L, &V);
        for (int i = 1; i <= n; ++ i)
        {
            scanf("%lf%lf%lf", &d[i], &v[i], &a[i]);
            if (a[i] > 0)
            {
                if (v[i] > V)
                {
                    x.push_back(mp(d[i], L));
                }
                else
                {
                    double tt = (V - v[i]) / a[i];
                    double ll = v[i] * tt + a[i] * tt * tt / 2.0 + d[i];
                    if (ll < L) 
                    {
                        x.push_back(mp(ll + eps, L));
                    }
                }
            }else if (a[i] == 0)
            {
                if (v[i] > V) x.push_back(mp(d[i], L));
            }else if (a[i] < 0)
            {
                if (v[i] > V)
                {
                    double tt = (v[i] - V) / (-a[i]);
                    double ll = v[i] * tt + a[i] * tt * tt / 2.0;
                    if (ll + d[i] > L) x.push_back(mp(d[i], L));
                    else x.push_back(mp(d[i], d[i] + ll - eps));
            }
        }
        for (int i = 1; i <= m; ++ i) scanf("%lf", &p[i]);
        p[0] = -1;
        sort(x.begin(), x.end());
        int num = x.size();
        int res = 0, cnt = 0;
        int ppp = 0;
        for (int i = 0; i < num; ++ i)
        {
            int pr = upper_bound(p + 1, p + m + 1, x[i].se) - p;
            int pl = lower_bound(p + 1, p + m + 1, x[i].fi) - p;
            if (p[pr - 1] < x[i].fi || p[pl] > x[i].se) continue;
            ++ res;
            if (ppp == 0 || p[pl] > p[ppp]) 
            {
                ++ cnt;
                ppp = pr - 1;
            }
            else ppp = min(ppp, pr - 1);
        }
        printf("%d %d\n", res, m - cnt);
    }
    return 0;
}
/*
9 10 110373 907
34507 939 -1
5901 998 -1
66753 982 -3
8013 970 -8
62012 959 -5
68954 984 -2
15403 987 -1
6321 991 -5
15081 981 -1
2491 7419 8047 15204 15495 36392 62765 69004 81638 90563
9 10 136382 369
54507 977 605
3911 760 -6
40194 861 -4
51022 665 -2
80430 821 -5
85729 821 -7
2895 754 -2
86004 904 -1
345 675 -1
10006 27479 38319 42148 48211 85717 87680 114851 121264 136382
*/